(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseHousekeepingFeeConfig: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseHousekeepingFeeConfigInfo: {
                housekeepingFeeConfigs: [],
                _currentHousekeepingFeeConfigName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseHousekeepingFeeConfig', 'openChooseHousekeepingFeeConfigModel', function (_param) {
                $('#chooseHousekeepingFeeConfigModel').modal('show');
                $that._refreshChooseHousekeepingFeeConfigInfo();
                $that._loadAllHousekeepingFeeConfigInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllHousekeepingFeeConfigInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        shopId: vc.getCurrentCommunity().shopId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('/housekeepingFeeConfig/queryHousekeepingFeeConfigs',
                    param,
                    function (json) {
                        var _housekeepingFeeConfigInfo = JSON.parse(json);
                        $that.chooseHousekeepingFeeConfigInfo.housekeepingFeeConfigs = _housekeepingFeeConfigInfo.housekeepingFeeConfigs;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseHousekeepingFeeConfig: function (_housekeepingFeeConfig) {
                if (_housekeepingFeeConfig.hasOwnProperty('name')) {
                    _housekeepingFeeConfig.housekeepingFeeConfigName = _housekeepingFeeConfig.name;
                }
                vc.emit($props.emitChooseHousekeepingFeeConfig, 'chooseHousekeepingFeeConfig', _housekeepingFeeConfig);
                vc.emit($props.emitLoadData, 'listHousekeepingFeeConfigData', {
                    housekeepingFeeConfigId: _housekeepingFeeConfig.housekeepingFeeConfigId
                });
                $('#chooseHousekeepingFeeConfigModel').modal('hide');
            },
            queryHousekeepingFeeConfigs: function () {
                $that._loadAllHousekeepingFeeConfigInfo(1, 10, $that.chooseHousekeepingFeeConfigInfo._currentHousekeepingFeeConfigName);
            },
            _refreshChooseHousekeepingFeeConfigInfo: function () {
                $that.chooseHousekeepingFeeConfigInfo._currentHousekeepingFeeConfigName = "";
            }
        }

    });
})(window.vc);
